package com.young.tool;

import java.util.Random;

/**
 * 描述:
 *
 * @author BluceYoung
 * @create 2020-12-02 19:56
 * B站：TeacherYoung凌风
 * www.teacheryoung.com
 */
public class ValidateCodeTool {

    /**
     * 生成一个4位的验证码数字
     * @return
     */
    public static String generateCode(){
        String str="0123456789";
        StringBuilder sb=new StringBuilder(4);
        for(int i=0;i<4;i++)
        {
            char ch=str.charAt(new Random().nextInt(str.length()));
            sb.append(ch);
        }
        return sb.toString();
    }
}
